import 'package:flutter_deer/generated/json/base/json_convert_content.dart';
import 'package:flutter_deer/database/beans/config/print_style_config.dart';

PrintStyleConfig $PrintStyleConfigFromJson(Map<String, dynamic> json) {
  final PrintStyleConfig printStyleConfig = PrintStyleConfig();
  final String? configKey = jsonConvert.convert<String>(json['configKey']);
  if (configKey != null) {
    printStyleConfig.configKey = configKey;
  }
  final List<PintConfigValue>? configValue = (json['configValue'] as List<dynamic>?)?.map(
          (e) => jsonConvert.convert<PintConfigValue>(e) as PintConfigValue).toList();
  if (configValue != null) {
    printStyleConfig.configValue = configValue;
  }
  return printStyleConfig;
}

Map<String, dynamic> $PrintStyleConfigToJson(PrintStyleConfig entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['configKey'] = entity.configKey;
  data['configValue'] = entity.configValue.map((v) => v.toJson()).toList();
  return data;
}

extension PrintStyleConfigExtension on PrintStyleConfig {
  PrintStyleConfig copyWith({
    String? configKey,
    List<PintConfigValue>? configValue,
  }) {
    return PrintStyleConfig()
      ..configKey = configKey ?? this.configKey
      ..configValue = configValue ?? this.configValue;
  }
}

PintConfigValue $PintConfigValueFromJson(Map<String, dynamic> json) {
  final PintConfigValue pintConfigValue = PintConfigValue();
  final String? typeName = jsonConvert.convert<String>(json['typeName']);
  if (typeName != null) {
    pintConfigValue.typeName = typeName;
  }
  final bool? choose = jsonConvert.convert<bool>(json['choose']);
  if (choose != null) {
    pintConfigValue.choose = choose;
  }
  final List<BaseShiftSetting>? list = (json['list'] as List<dynamic>?)?.map(
          (e) => jsonConvert.convert<BaseShiftSetting>(e) as BaseShiftSetting).toList();
  if (list != null) {
    pintConfigValue.list = list;
  }
  final String? typeCode = jsonConvert.convert<String>(json['typeCode']);
  if (typeCode != null) {
    pintConfigValue.typeCode = typeCode;
  }
  final String? valueCode = jsonConvert.convert<String>(json['valueCode']);
  if (valueCode != null) {
    pintConfigValue.valueCode = valueCode;
  }
  return pintConfigValue;
}

Map<String, dynamic> $PintConfigValueToJson(PintConfigValue entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['typeName'] = entity.typeName;
  data['choose'] = entity.choose;
  data['list'] = entity.list.map((v) => v.toJson()).toList();
  data['typeCode'] = entity.typeCode;
  data['valueCode'] = entity.valueCode;
  return data;
}

extension PintConfigValueExtension on PintConfigValue {
  PintConfigValue copyWith({
    String? typeName,
    bool? choose,
    List<BaseShiftSetting>? list,
    String? typeCode,
    String? valueCode,
  }) {
    return PintConfigValue()
      ..typeName = typeName ?? this.typeName
      ..choose = choose ?? this.choose
      ..list = list ?? this.list
      ..typeCode = typeCode ?? this.typeCode
      ..valueCode = valueCode ?? this.valueCode;
  }
}

BaseShiftSetting $BaseShiftSettingFromJson(Map<String, dynamic> json) {
  final BaseShiftSetting baseShiftSetting = BaseShiftSetting();
  final String? defaultCheckboxCode = jsonConvert.convert<String>(json['defaultCheckboxCode']);
  if (defaultCheckboxCode != null) {
    baseShiftSetting.defaultCheckboxCode = defaultCheckboxCode;
  }
  final String? itemCode = jsonConvert.convert<String>(json['itemCode']);
  if (itemCode != null) {
    baseShiftSetting.itemCode = itemCode;
  }
  final bool? choose = jsonConvert.convert<bool>(json['choose']);
  if (choose != null) {
    baseShiftSetting.choose = choose;
  }
  final List<ItemPrintSetting>? itemList = (json['itemList'] as List<dynamic>?)?.map(
          (e) => jsonConvert.convert<ItemPrintSetting>(e) as ItemPrintSetting).toList();
  if (itemList != null) {
    baseShiftSetting.itemList = itemList;
  }
  final List<String>? chooseCheckboxCodes = (json['chooseCheckboxCodes'] as List<dynamic>?)?.map(
          (e) => jsonConvert.convert<String>(e) as String).toList();
  if (chooseCheckboxCodes != null) {
    baseShiftSetting.chooseCheckboxCodes = chooseCheckboxCodes;
  }
  final String? valueCode = jsonConvert.convert<String>(json['valueCode']);
  if (valueCode != null) {
    baseShiftSetting.valueCode = valueCode;
  }
  return baseShiftSetting;
}

Map<String, dynamic> $BaseShiftSettingToJson(BaseShiftSetting entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['defaultCheckboxCode'] = entity.defaultCheckboxCode;
  data['itemCode'] = entity.itemCode;
  data['choose'] = entity.choose;
  data['itemList'] = entity.itemList.map((v) => v.toJson()).toList();
  data['chooseCheckboxCodes'] = entity.chooseCheckboxCodes;
  data['valueCode'] = entity.valueCode;
  return data;
}

extension BaseShiftSettingExtension on BaseShiftSetting {
  BaseShiftSetting copyWith({
    String? defaultCheckboxCode,
    String? itemCode,
    bool? choose,
    List<ItemPrintSetting>? itemList,
    List<String>? chooseCheckboxCodes,
    String? valueCode,
  }) {
    return BaseShiftSetting()
      ..defaultCheckboxCode = defaultCheckboxCode ?? this.defaultCheckboxCode
      ..itemCode = itemCode ?? this.itemCode
      ..choose = choose ?? this.choose
      ..itemList = itemList ?? this.itemList
      ..chooseCheckboxCodes = chooseCheckboxCodes ?? this.chooseCheckboxCodes
      ..valueCode = valueCode ?? this.valueCode;
  }
}

ItemPrintSetting $ItemPrintSettingFromJson(Map<String, dynamic> json) {
  final ItemPrintSetting itemPrintSetting = ItemPrintSetting();
  final String? checkboxCode = jsonConvert.convert<String>(json['checkboxCode']);
  if (checkboxCode != null) {
    itemPrintSetting.checkboxCode = checkboxCode;
  }
  final String? checkboxName = jsonConvert.convert<String>(json['checkboxName']);
  if (checkboxName != null) {
    itemPrintSetting.checkboxName = checkboxName;
  }
  final String? checkboxValue = jsonConvert.convert<String>(json['checkboxValue']);
  if (checkboxValue != null) {
    itemPrintSetting.checkboxValue = checkboxValue;
  }
  final String? valueCode = jsonConvert.convert<String>(json['valueCode']);
  if (valueCode != null) {
    itemPrintSetting.valueCode = valueCode;
  }
  return itemPrintSetting;
}

Map<String, dynamic> $ItemPrintSettingToJson(ItemPrintSetting entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['checkboxCode'] = entity.checkboxCode;
  data['checkboxName'] = entity.checkboxName;
  data['checkboxValue'] = entity.checkboxValue;
  data['valueCode'] = entity.valueCode;
  return data;
}

extension ItemPrintSettingExtension on ItemPrintSetting {
  ItemPrintSetting copyWith({
    String? checkboxCode,
    String? checkboxName,
    String? checkboxValue,
    String? valueCode,
  }) {
    return ItemPrintSetting()
      ..checkboxCode = checkboxCode ?? this.checkboxCode
      ..checkboxName = checkboxName ?? this.checkboxName
      ..checkboxValue = checkboxValue ?? this.checkboxValue
      ..valueCode = valueCode ?? this.valueCode;
  }
}

PrintCouponStyleBean $PrintCouponStyleBeanFromJson(Map<String, dynamic> json) {
  final PrintCouponStyleBean printCouponStyleBean = PrintCouponStyleBean();
  final String? couponName = jsonConvert.convert<String>(json['couponName']);
  if (couponName != null) {
    printCouponStyleBean.couponName = couponName;
  }
  final String? goodsQuantity = jsonConvert.convert<String>(json['goodsQuantity']);
  if (goodsQuantity != null) {
    printCouponStyleBean.goodsQuantity = goodsQuantity;
  }
  final String? mchGoodsName = jsonConvert.convert<String>(json['mchGoodsName']);
  if (mchGoodsName != null) {
    printCouponStyleBean.mchGoodsName = mchGoodsName;
  }
  final String? consumeIntegral = jsonConvert.convert<String>(json['consumeIntegral']);
  if (consumeIntegral != null) {
    printCouponStyleBean.consumeIntegral = consumeIntegral;
  }
  final String? payAmount = jsonConvert.convert<String>(json['payAmount']);
  if (payAmount != null) {
    printCouponStyleBean.payAmount = payAmount;
  }
  return printCouponStyleBean;
}

Map<String, dynamic> $PrintCouponStyleBeanToJson(PrintCouponStyleBean entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['couponName'] = entity.couponName;
  data['goodsQuantity'] = entity.goodsQuantity;
  data['mchGoodsName'] = entity.mchGoodsName;
  data['consumeIntegral'] = entity.consumeIntegral;
  data['payAmount'] = entity.payAmount;
  return data;
}

extension PrintCouponStyleBeanExtension on PrintCouponStyleBean {
  PrintCouponStyleBean copyWith({
    String? couponName,
    String? goodsQuantity,
    String? mchGoodsName,
    String? consumeIntegral,
    String? payAmount,
  }) {
    return PrintCouponStyleBean()
      ..couponName = couponName ?? this.couponName
      ..goodsQuantity = goodsQuantity ?? this.goodsQuantity
      ..mchGoodsName = mchGoodsName ?? this.mchGoodsName
      ..consumeIntegral = consumeIntegral ?? this.consumeIntegral
      ..payAmount = payAmount ?? this.payAmount;
  }
}